package cn.tedu.m3;


import org.springframework.amqp.core.FanoutExchange;

import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;


@SpringBootApplication
public class Main {

        public static void main(String[] args) {
                SpringApplication.run(Main.class, args);
        }
        @Bean
        public FanoutExchange fanoutExchange() {
                //参数 1；名字 2，持久  3，自动删除
                //默认是持久交换机
                return new FanoutExchange("logs",false,false);
        }
        @Bean
        public Queue helloworldQueue() {
                return new Queue("task-queue", true);
        }

        //用生产者发送消息
        @Autowired
        private Producer p;


        @PostConstruct
        public void test() {
                new Thread(() -> p.send()).start();
        }

}